// VObject.cpp
//
#include "VObject.h"

static unsigned int idPool = 0;

OpenGL::Color  VObject::_selectionColor;
OpenGL::Color  VObject::_hilightColor;

// ------------------------------------------------------------------------------------------------
VObject::VObject()
: _selected(false),
  _hilighted(false),
  _name("")
{
	_id = idPool++;
}

// ------------------------------------------------------------------------------------------------
void VObject::setName( const std::string &name )	{ _name      = name; }
void VObject::setSelected( bool on )				{ _selected  = on;   }
void VObject::setHilighted( bool on )				{ _hilighted = on;   }

// ------------------------------------------------------------------------------------------------
void VObject::setSelectionColor( const OpenGL::Color &c )	{ _selectionColor = c; }
void VObject::setHilightColor( const OpenGL::Color &c )		{ _hilightColor   = c; }

// ------------------------------------------------------------------------------------------------
unsigned int VObject::id() const                { return _id;}
std::string VObject::name() const           	{ return _name; }
bool VObject::isSelected() const	            { return _selected;}
bool VObject::isHilighted() const               { return _hilighted;}
bool VObject::isVisible() const				    { return _visible; }
OpenGL::Math::box3 VObject::boundingBox() const { return _boundingBox; }
VObject::ObjectType VObject::type() const		{ return Unknown; }

// ------------------------------------------------------------------------------------------------
void VObject::draw( OpenGL::Renderer *r ) const {}

// ------------------------------------------------------------------------------------------------
void VObject::drawForSelection( OpenGL::Renderer *r ) const {}

// ------------------------------------------------------------------------------------------------
void VObject::setColor( const OpenGL::Color &c )
{
	_color = c;
}

// ------------------------------------------------------------------------------------------------
OpenGL::Color VObject::color() const
{
	OpenGL::Color c;

	switch( ((int)_selected)<<1 | (int)_hilighted )
	{
	case 0:	c = _color;						break;
	case 1:	c = _hilightColor;				break;	// hilighted color
	case 2: c = _selectionColor;			break;	// selected color
	case 3:	c = _selectionColor.lighter();	break;	// selected and hilighted
	}

	return c;
}

// ------------------------------------------------------------------------------------------------
bool VObject::intersects( const OpenGL::Math::box3 &b )  const
{
	return false;
}
